package ua.kharkov.knure.pereverziev.diploma.web.command.admincommand;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;

import ua.kharkov.knure.pereverziev.diploma.web.command.AirportDateChoiceCommand;
import ua.kharkov.knure.pereverziev.diploma.web.command.Command;

public class Administration implements Command {

	private static final Logger log = Logger
			.getLogger(AirportDateChoiceCommand.class);

	@Override
	public String execute(final HttpServletRequest request,
			final HttpServletResponse response) throws IOException,
			ServletException {

		final HttpSession session = request.getSession();

		final String administration = request.getParameter("administration");
		log.debug("Request parameter: administration --> " + administration);

		session.setAttribute("isAdministration", administration);

		final String forward;
		if ("true".equals(administration))
			forward = "WEB-INF/jsp/administration/mainAdministrationPage.jsp";
		else
			forward = "WEB-INF/jsp/mainPage.jsp";

		return forward;
	}
}
